package com.wjw.java.basic.method_;

/**
 * 成员方法传参机制：传递基本数据类型：见member_method_basic_param_jvm.png
 * 形参值的变化不会改变实参的值,因为形参和实参在不同的栈内存中
 */
public class MemberMethodBasicParam {

    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        BasicParam bp = new BasicParam();
        bp.swap(a,b);
        System.out.println("main方法中的a:"+a+",b:"+b);//a=10,b=20
    }
}

class BasicParam{
    //a和b的值交换
    public void swap(int a,int b){
        System.out.println("交换前a:"+a+",b:"+b);//a=10,b=20
        int temp = a;
        a = b;
        b = temp;
        System.out.println("交换后a:"+a+",b:"+b);//a=20,b=10
    }
}
